import asyncio

"""
    方式四：python 3.5以后的写法，官方推荐使用
"""


async def hello():
    print("1")
    await asyncio.sleep(1)
    print("2")


async def wget():
    print('3')
    await asyncio.sleep(1)
    print('4')


tasks = [
    asyncio.ensure_future(hello()),
    asyncio.ensure_future(wget())
]

loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(tasks))
